package com.htjc.integral.conversion.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.htjc.integral.conversion.mapper.EcBpMemberDetailMapper;
import com.htjc.integral.conversion.mapper.EcCorporationBoundExtMapper;
import com.htjc.integral.conversion.service.IEcCorporationBoundService;
import com.htjc.integral.conversion.service.IEcbpExchangeService;
import com.htjc.integral.conversion.service.IGdtService;
import com.htjc.integral.model.conversion.EcBpMemberDetail;

import lombok.extern.slf4j.Slf4j;

@Slf4j(topic = "conversionLogger")
@Service
public class EcCorporationBoundServiceImpl implements IEcCorporationBoundService {
	@Autowired
	IGdtService gdtServiceImpl;
	
	@Autowired
	private EcCorporationBoundExtMapper ecCorporationBoundExtMapper;

	@Autowired
	IEcbpExchangeService ecbpExchangeServiceImpl;
	
	@Autowired
	private EcBpMemberDetailMapper ecBpMemberDetailMapper;
	
	//111
	@Override
	public int updateValueByCode(int coUserValue, int corporationDvalue,
			String applicationUserCode,String id,String addressCard) throws Exception {
		Map<String, Object> mapParam = new HashMap<String, Object>();
		mapParam.put("coUserValue", coUserValue);
		mapParam.put("corporationDvalue", corporationDvalue);
		mapParam.put("applicationUserCode", applicationUserCode);
		mapParam.put("id", id);
		mapParam.put("addressCard", addressCard);
		return this.ecCorporationBoundExtMapper.updateValueByCode(mapParam);
	}

	//222
	@Override
	public List<Map<String, String>> selectCorporationBound(String partnerId,
			String corporationId) throws Exception {
		long t1 = System.currentTimeMillis();
		Map<String, String> map = new HashMap<String, String>();
		map.put("partnerId", partnerId);
		map.put("corporationId", corporationId);
		List<Map<String, String>> list = this.ecCorporationBoundExtMapper.selectCorporationBound(map);
		//由于前台不能发包，需要把查询出的消费积分与前台字段名进行匹配===========aaa============感觉无用的代码，注释掉了
//		String corporationDvalue;
//		for(Map<String, String> mapInfo : list){
//			corporationDvalue = map.get("TOTAL_BONUS_POINTS");
//			mapInfo.put("totalConsumelIntegral", corporationDvalue);
//		}
		//由于前台不能发包，需要把查询出的消费积分与前台字段名进行匹配===========aaa============感觉无用的代码，注释掉了
		long t2 = System.currentTimeMillis();
		log.info("=+=+=+=++=+=++=+=+==+    查询账户绑定列表sql执行时间为：" + (t2-t1));
		return list;
	}

	//333
	@Override
	public List<EcBpMemberDetail> getConsNoIntegralDetail(Map<String, String> map)throws Exception {
		return this.ecBpMemberDetailMapper.getConsNoIntegralDetail(map);
	}

	//111
	@Override
	public List<Map<String, String>> checkMobile(String partnerId,
			String corporationId, String applicationUserCode, String addressCard)
			throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		map.put("partnerId", partnerId);
		map.put("corporationId", corporationId);
		map.put("applicationUserCode", applicationUserCode);
		map.put("addressCard", addressCard);
		return this.ecCorporationBoundExtMapper.checkMobile(map);
	}

	//222
	@Override
	public int selectCorporationBoundCount(String partnerId,
			String corporationId) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		map.put("partnerId", partnerId);
		map.put("corporationId", corporationId);
		return this.ecCorporationBoundExtMapper.selectCorporationBoundCount(map);
	}

}